Hi Ross/Bengt
Regarding PoKeys: Yes as far as I know it should work with KFlop and/or in parallel with some other MPG as it basically issues commands to Mach3, so from KFlop's standpoint it is no different then pushing buttons directly on the screen to cause movement and events. I think both can be "active" at the same time (use one then use the other) but I'm not sure if both will work simultaneously (as in causing diagonal motion). Actually in Mach3 Jogging at constant velocity is treated differently than Jogging "steps". The later is treated the same as multi-axis coordinated GCode motion where the first just tells the plugin to jog.
Regarding 2 MPG hand wheels: There is no need to use both Aux connectors. One should be enough as long as there are enough I/O bits on one (each has 10). We will need to change the MPG C program to handle two wheels simultaneously anyway. The example: Init3AnalogPlusMPG.c has definitions to define where one handwheel is connected (QA, QB). It then does some calculations involving some variables which results in how much the handwheel moved in a variable called Change1. This change is then applied to one of the axes multiplied by a Factor based on some input switches. Below I've show the code that works for one handwheel and below that modified code that should work with two handwheels. Note that in the second cas we need to create different variables (the _2 differentiates them) to keep track of the 2nd Handwheel's position and changes.
(I've also attached a file called Init3AnalogPlusTwoMPGs.c)
I hope this helps
TK
Here is the code to control multiple axes from one handwheel:
#define QA 26 // define to which IO bits the AB signals are connected
#define QB 27
int BitA,Change1=0,Change2=0, DiffX2;
int PosNoWrap, NewPos, Pos=0, wraps;
double Factor=0;
// convert quadrature to 2 bit binary
BitA = ReadBit(QA);
PosNoWrap = (ReadBit(QB) ^ BitA) | (BitA<<1);
// Diff between expected position based on average of two prev deltas
// and position with no wraps. (Keep as X2 to avoid division by 2)
DiffX2 = 2*(Pos-PosNoWrap) + (Change2+Change1);
// Calc quadrature wraparounds to bring Diff nearest zero
// offset by 128 wraps to avoid requiring floor()
wraps = ((DiffX2+1028)>>3)-128;
// factor in the quadrature wraparounds
NewPos = PosNoWrap + (wraps<<2);
Change2 = Change1;
Change1 = NewPos - Pos;
Pos = NewPos;
if (ReadBit(31)) // is X1 selected?
Factor = 1.0;
else if (ReadBit(32)) // is X100 selected?
Factor = 75.0;
else // must be X10 then
Factor = 10.0;
if (ReadBit(28)) // is x selected?
ch0->Dest += Change1 * Factor;
else if (ReadBit(29)) // is y selected?
ch1->Dest += Change1 * Factor;
else if (ReadBit(30)) // is z selected?
ch2->Dest += Change1 * Factor;
Here is code to handle 2 axes from 2 handwheels
#define QA 26 // define to which IO bits the AB signals for wheel#1 are connected
#define QB 27
#define QA_2 28 // define to which IO bits the AB signals for wheel#2 are connected
#define QB_2 29
int Change1=0, Change2=0, Pos=0;
int Change1_2=0,Change2_2=0, Pos_2=0;
int BitA, DiffX2, PosNoWrap, NewPos, wraps;
// DO 1ST HANDWHEEL
// convert quadrature to 2 bit binary
BitA = ReadBit(QA);
PosNoWrap = (ReadBit(QB) ^ BitA) | (BitA<<1);
// Diff between expected position based on average of two prev deltas
// and position with no wraps. (Keep as X2 to avoid division by 2)
DiffX2 = 2*(Pos-PosNoWrap) + (Change2+Change1);
// Calc quadrature wraparounds to bring Diff nearest zero
// offset by 128 wraps to avoid requiring floor()
wraps = ((DiffX2+1028)>>3)-128;
// factor in the quadrature wraparounds
NewPos = PosNoWrap + (wraps<<2);
Change2 = Change1;
Change1 = NewPos - Pos;
Pos = NewPos;
// DO 2ND HANDWHEEL
// convert quadrature to 2 bit binary
BitA = ReadBit(QA_2);
PosNoWrap = (ReadBit(QB_2) ^ BitA) | (BitA<<1);
// Diff between expected position based on average of two prev deltas
// and position with no wraps. (Keep as X2 to avoid division by 2)
DiffX2 = 2*(Pos_2-PosNoWrap) + (Change2_2+Change1_2);
// Calc quadrature wraparounds to bring Diff nearest zero
// offset by 128 wraps to avoid requiring floor()
wraps = ((DiffX2+1028)>>3)-128;
// factor in the quadrature wraparounds
NewPos = PosNoWrap + (wraps<<2);
Change2_2 = Change1_2;
Change1_2 = NewPos - Pos_2;
Pos_2 = NewPos;
// Read Speed Selector
if (ReadBit(31)) // is X1 selected?
Factor = 1.0;
else if (ReadBit(32)) // is X100 selected?
Factor = 75.0;
else // must be X10 then
Factor = 10.0;
ch0->Dest += Change1 * Factor;
ch1->Dest += Change1_2 * Factor;
Group: DynoMotion |
Message: 440 |
From: fermanz |
Date: 6/13/2010 |
Subject: Re: Collision or not? |
Thanks Tom,
I knew there would be some simple parts to the answer :)
I see that we retain the speed selection of x, x10, and x100.
I take it we no longer select an axis?
And we enable both handwheels with one on/off switch.
Is there something in the code that disables all other inputs, such as keyboard, or MDI, etc. as soon as the handwheels are enabled?
Ross
P.S. I can't find the Init3AnalogPlusTwoMPGs.c file attached, although I can just copy and paste it from here.
--- In DynoMotion@yahoogroups.com, Tom Kerekes <tk@...> wrote:
>
> Hi Ross/Bengt
>
> Regarding PoKeys: Yes as far as I know it should work with KFlop and/or in parallel with some other MPG as it basically issues commands to Mach3, so from KFlop's standpoint it is no different then pushing buttons directly on the screen to cause movement and events. I think both can be "active" at the same time (use one then
<<<<clipped>>>>>
>
|
|
Group: DynoMotion |
Message: 441 |
From: Tom Kerekes |
Date: 6/13/2010 |
Subject: Re: Collision or not? |
Hi Ross,
Yes the code to do the speed selection is left in. You can delete it (and set a fixed speed Factor) if you don't have a speed switch.
Yes the two hand wheels are fixed to axis0 and axis1. I assume that is what you want.
No - there is no enable switch, but disabling the handwheels would be easy. Just put a "if" condition around the whole block of code. But I'm not sure how to disable Mach3's keyboard. It seems to me unlikely that an operator would type something while turning the handwheels. But I do think it would be possible for someone to bump a handwheel while GCode is running. I think this might be protected already because a motion trajectory controlling the commanded destination will overwrite any changes a User program tries to make to the commanded destinations.
Another approach would be to use the Mach3 Offline mode to enable the handwheels. Does that sound like a good idea?
But let's get it all working first, then we can work on the more subtle details.
TK
| |